package cn.com.open.itembank.service;

import cn.com.open.itembank.dto.ChapterInputModel;
import cn.com.open.itembank.dto.ReturnModel;
import cn.com.open.itembank.entity.Chapter;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by lucky on 2017/9/5.
 */
@FeignClient(name = "item-base-service")
public interface ChapterService {

    //region 新增相关

    /**
     * 新增章节
     *
     * @param chapterModel
     * @return
     */
    @PostMapping(value = "/itembank/{itembankId}/chapter")
    ReturnModel insert(@PathVariable(value = "itembankId") String itembankId,@RequestBody Chapter chapterModel);

    //endregion

    //region 获取相关

    /**
     * 获取章节信息
     *
     * @param itembankId the itembankId
     * @param chapterId  the chapterId
     * @return 可用题库列表
     */
    @GetMapping(value = "/itembank/{itembankId}/chapter/{chapterId}/getmodel")
    Chapter getChapterInfo(@PathVariable(value = "itembankId") String itembankId, @PathVariable(value = "chapterId") String chapterId);


    /**
     * 获取课程全部章节
     *
     * @param itembankId itembankId
     * @return 可用题库列表
     */
    @GetMapping(value = "/itembank/{itembankId}/chapterlist")
    ReturnModel getCourseChapter(@RequestParam("appKey") String appKey,
                             @PathVariable(value = "itembankId") String itembankId);


    /**
     * 获取课程题库下所有章节列表(树)
     *
     * @param itembankId itembankId
     * @return 可用题库列表
     */
    @GetMapping(value = "/itembank/{itembankId}/chaptertree")
    ReturnModel getAllChaptList(@RequestParam("appKey") String appKey,
                            @PathVariable(value = "itembankId") String itembankId);

    /**
     * 获取章节（策略用）
     *
     * @param itembankId itembankId
     * @return 可用题库列表
     */
    @GetMapping(value = "/itembank/{itembankId}/getchildchapterbyguid")
    ReturnModel getChaptForRules(@RequestParam("appKey") String appKey,
                             @PathVariable("itembankId") String itembankId,
                             @PathVariable("firstChapterId") String firstChapterId,
                             @PathVariable("lastChapterId") String lastChapterId);

    /**
     * 获取章节（策略修改用）
     *
     * @param itembankId itembankId
     * @return 可用题库列表
     */
    @GetMapping(value = "/itembank/{itembankId}/getcheckchapterbyguid")
    ReturnModel getChaptForUpdateRules(@RequestParam("appKey") String appKey,
                                   @PathVariable("itembankId") String itembankId,
                                   @PathVariable("chapterId") String chapterId);

    /**
     * 获取章节获取(根据章节集合和章节id串)
     *
     * @param itembankId itembankId
     * @param chapter    chapter
     * @return 可用题库列表
     */
    @GetMapping(value = "/itembank/{itembankId}/chapter/{chapterId}/getlist")
    ReturnModel getChildModel(@RequestParam("appKey") String appKey,
                          @PathVariable("itembankId") String itembankId,
                          @RequestBody List<Chapter> chapter,
                          @PathVariable("chapterId") String chapterId);

    //endregion

    //region 修改相关

    /**
     * 修改章节名称.
     *
     * @param chapterId
     * @param chapterName
     * @return
     */
    @PutMapping(value = "/itembank/{itembankId}/chapter/{chapterId}")
    ReturnModel updateChapterName(@RequestParam("appKey") String appKey,
            @PathVariable("itembankId") String itembankId,
            @PathVariable("chapterId") String chapterId,
                                  @RequestBody String chapterName);

    /**
     * 拖拽更新章节
     *
     * @param appKey
     * @param itembankId
     * @param chapterId
     * @param parentId
     * @param type
     * @return
     */
    @PutMapping(value = "/itembank/{itembankId}/chapter/{chapterId}/drag")
    ReturnModel updateChapter(@RequestParam("appKey") String appKey,
                              @PathVariable("itembankId") String itembankId,
                              @PathVariable("chapterId") String chapterId,
                              @RequestParam("parentId") String parentId,
                              @RequestParam("type") Integer type);


    /**
     * 拖拽后数据同步
     *
     * @param appKey
     * @param itembankId
     * @param chapterInputModel
     * @return
     */
    @PutMapping(value = "/itembank/{itembankId}/chapter/dragchapter")
    ReturnModel dragChapter(@RequestParam("appKey") String appKey,
                            @PathVariable("itembankId") String itembankId,
                            @RequestBody ChapterInputModel chapterInputModel);

    //endregion

    //region 删除相关

    /**
     * 删除题库下全部章节信息.
     *
     * @param itembankId
     * @return
     */
    @DeleteMapping(value = "/itembank/{itembankId}/chapter")
    ReturnModel deleteByItemBankId(@PathVariable("itembankId") String itembankId);

    /**
     * 根据章节ID删除章节信息
     * @param itembankId
     * @return
     */
    @DeleteMapping(value = "/itembank/{itembankId}/chapter/{chapterId}/deletechapter")
    ReturnModel deleteById(@RequestParam("appKey") String appKey,
                           @PathVariable("itembankId") String itembankId,
                           @PathVariable("chapterId") String chapterId);

    /**
     * 根据子章节ID删除章节信息
     *
     * @param itembankId
     * @return
     */
    @DeleteMapping(value = "/itembank/{itembankId}/chapter/{chapterId}")
    ReturnModel deleteByChildId(@RequestParam("appKey") String appKey,
                                @PathVariable("itembankId") String itembankId,
                                @PathVariable("chapters") String chapters,
                                @PathVariable("chapterId") String chapterId);


    //endregion

}
